package leetcode;

public class LeetCode122 {
    //要学会拆分问题 上升区间相加
    //波峰波谷 只要上升曲线
    public int maxProfit(int[] prices) {
        int result = 0;
        for (int i = 0; i < prices.length - 1; i++) {
            result += Math.max(prices[i + 1] - prices[i], 0);
        }
        return result;
    }
//------------------------------------------------------------------
}
